//
//  AppDelegate.m
//  微博 OC
//
//  Created by 黑眼圈 on 16/4/18.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "AppDelegate.h"
#import "HZTabBc.h"
#import "HZWecomeVc.h"
//#import "HZBaseTableViewController.h"
#import "HZTabBc.h"
#import "HZOAuthVM.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //接收通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeRootVc:) name:@"wecome" object:nil];
    
    
    //创建主窗口
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    
    //设置根控制器HZTabBc
    
    //如果登录过就显示欢迎界面,没有登录过就显示访客界面
    BOOL iss = [[HZOAuthVM sharedOAuth] isslogined];
    
    if (iss == NO) {
        
        self.window.rootViewController = [[HZTabBc alloc]init];
    }else{
        
        self.window.rootViewController = [[HZWecomeVc alloc]init];
    }
    
    
    
    
    
    
    //设置为主窗口并可见
    [self.window makeKeyAndVisible];
    
 
    [self setAppearance];
    
    
    
    
    
    return YES;
}

#pragma mark -
#pragma mark    接收通知的方法
-(void)changeRootVc:(NSNotification*)noti{
    
    //    NSLog(@"efefwe");
    
    if (noti.object) {
        
        //跳转到欢迎界面
        HZWecomeVc* wecomeVc = [[HZWecomeVc alloc]init];
        
        self.window.rootViewController = wecomeVc;
        
        
    }else{
        
        // 跳转到主界面
//        [[HZOAuthVM sharedOAuth] islogined]
        
        HZTabBc* tabBc = [[HZTabBc alloc]init];
        
        
        
        self.window.rootViewController = tabBc;
    }
    
  
}


#pragma mark -
#pragma mark     设置全局的外观对象
-(void)setAppearance{
  
    UITabBar* bar =[UITabBar appearance];
    
    bar.tintColor = [UIColor orangeColor];
    
    
    UINavigationBar* navBar = [UINavigationBar appearance];
    
    navBar.tintColor = [UIColor orangeColor];
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
